//
//  WeiDianLeiJiShouRuViewController.m
//  EJLX
//
//  Created by adc on 15/11/16.
//  Copyright © 2015年 江苏一键联信息科技有限公司. All rights reserved.
//

#import "WeiDianLeiJiShouRuViewController.h"
#import "WeiDianLeiJiShouRuTableViewCell.h"
#import "WeiDianLeiJiShouRu.h"
@interface WeiDianLeiJiShouRuViewController ()

@end

@implementation WeiDianLeiJiShouRuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [HttpsManager requestWeiDianLeiJiShouRuCompletion:^(NSMutableArray *shouRuAry)
    {
        if (shouRuAry==nil)
        {
            LoginVC*VC=[[LoginVC alloc]init];
            [self.navigationController pushViewController:VC animated:YES];
        }
        else
        {
            
            _dataAry=shouRuAry;
            __weak WeiDianLeiJiShouRuViewController *weakSelf = self;
            [tabel addPullToRefreshWithActionHandler:^{
                NSLog(@"当进行下拉刷新执行该方法");
                [weakSelf performSelector:@selector(requestEnd) withObject:nil afterDelay:1.0f];
            }];
            
            [tabel addInfiniteScrollingWithActionHandler:^{
                [weakSelf performSelector:@selector(requestEnd) withObject:nil afterDelay:1.0f];
            }];

            [tabel reloadData];
            
        }
    }];
    // Do any additional setup after loading the view from its nib.
    UIView*view=[[UIView alloc]initWithFrame:CGRectMake(0, 20,WIDE, 44)];
    view.backgroundColor=RGB_COLOR(0x00c49f);
    [self.view addSubview:view];
    UIButton*backBut=[[UIButton alloc]initWithFrame:CGRectMake(10, 7, 30, 30)];
    [backBut setImage:[UIImage imageNamed:@"返回箭头"] forState:UIControlStateNormal];
    [backBut addTarget:self action:@selector(backBut) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:backBut];
    UILabel*label=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/2-55, 10,110, 24)];
    label.text=@"微店累计收入";
    label.textAlignment=NSTextAlignmentCenter;
    label.textColor=[UIColor whiteColor];
    [view addSubview:label];
//    for (int i=0; i<4; i++)
//    {
//        UIButton*but=[[UIButton alloc]initWithFrame:CGRectMake(0+WIDE/4*i,64,WIDE/4, 50)];
//        NSArray*ary=[NSArray arrayWithObjects:@"盈利",@"退款",@"获利",@"结算纪录", nil];
//        but.font=[UIFont systemFontOfSize:12];
//        [but setTitle:ary[i] forState:UIControlStateNormal];
//        [but setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//        [but addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
//        but.tag=i;
//        [self.view addSubview:but];
//    }
//    label1=[[UILabel alloc]initWithFrame:CGRectMake(0, 64+50,WIDE/4,2)];
//    label1.backgroundColor=RGB_COLOR(0x00c49f);
//    [self.view addSubview:label1];
    tabel=[[UITableView alloc]initWithFrame:CGRectMake(0, 64+20,WIDE,HEIGHT-64-20) style:UITableViewStyleGrouped];
    tabel.delegate=self;
    tabel.dataSource=self;
    tabel.rowHeight=70;
    [self.view addSubview:tabel];
    [tabel registerNib:[UINib nibWithNibName:@"WeiDianLeiJiShouRuTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
//    UILabel*yL1=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/4-50,HEIGHT-100,50,20)];
//    yL1.text=@"盈利:";
//    yL1.textColor=[UIColor blackColor];
//    [self.view addSubview:yL1];
//    UILabel*yL2=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/4,HEIGHT-100,60,20)];
//    yL2.text=@"0.00元";
//    
//    yL2.textColor=[UIColor blackColor];
//    [self.view addSubview:yL2];
//    UILabel*hL1=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/4+130,HEIGHT-100,50,20)];
//    hL1.text=@"获利:";
//    hL1.textColor=[UIColor blackColor];
//    [self.view addSubview:hL1];
//    UILabel*hL2=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/4+170,HEIGHT-100,60,20)];
//    hL2.text=@"0.00元";
//    
//    hL2.textColor=[UIColor blackColor];
//    [self.view addSubview:hL2];
//    
//    UIButton*jieSuanBut1=[[UIButton alloc]initWithFrame:CGRectMake(WIDE/4-45,HEIGHT-70,90,20)];
//    [jieSuanBut1 setTitle:@"申请结算" forState:UIControlStateNormal];
//    jieSuanBut1.backgroundColor=RGB_COLOR(0x00c49f);
//    [jieSuanBut1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [jieSuanBut1 addTarget:self action:@selector(jieSuanBut1) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:jieSuanBut1];
//    UIButton*jieSuanBut2=[[UIButton alloc]initWithFrame:CGRectMake(WIDE/4+130,HEIGHT-70,90,20)];
//    [jieSuanBut2 setTitle:@"申请结算" forState:UIControlStateNormal];
//    jieSuanBut2.backgroundColor=RGB_COLOR(0x00c49f);
//    [jieSuanBut2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [jieSuanBut2 addTarget:self action:@selector(jieSuanBut2) forControlEvents:UIControlEventTouchUpInside];
//    
//    [self.view addSubview:jieSuanBut2];
//    UILabel*yJS1=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/4-60,HEIGHT-40,60,20)];
//    yJS1.text=@"已结算:";
//    yJS1.textColor=[UIColor blackColor];
//    [self.view addSubview:yJS1];
//    UILabel*yJS2=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/4, HEIGHT-40,60,20)];
//    yJS2.text=@"0.00元";
//    
//    yJS2.textColor=[UIColor blackColor];
//    [self.view addSubview:yJS2];
//    UILabel*yJS3=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/4+120,HEIGHT-40,60,20)];
//    yJS3.text=@"已结算:";
//    yJS3.textColor=[UIColor blackColor];
//    [self.view addSubview:yJS3];
//    UILabel*yJS4=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/4+175,HEIGHT-40,60,20)];
//    yJS4.text=@"0.00元";
//    
//    yJS4.textColor=[UIColor blackColor];
//    [self.view addSubview:yJS4];
}
- (void)requestEnd{
    [tabel.pullToRefreshView stopAnimating];
    
    [tabel.infiniteScrollingView stopAnimating];
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataAry.count;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WeiDianLeiJiShouRu*weiDian=_dataAry[indexPath.row];
    WeiDianLeiJiShouRuTableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.shiDeJinE.text=[NSString stringWithFormat:@"%f",weiDian.realIncome*0.01];
    cell.name1.text=[NSString stringWithFormat:@"%f",weiDian.profit*0.01];
    cell.time.text=weiDian.time;
    
    return cell;
}
-(void)butClick:(UIButton*)sender
{
    
    [UIView animateWithDuration:0.2 animations:^{
        
        label1.frame=CGRectMake(0+WIDE/4*sender.tag, 64+50,WIDE/4,2);
        
        
        
    } completion:^(BOOL finished) {
        nil;
    }];
    
}
-(void)jieSuanBut2
{
    NSLog(@"11");
}
-(void)jieSuanBut1
{
    NSLog(@"22");
}
-(void)backBut
{
    [self.navigationController popViewControllerAnimated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
